package sprg;

import java.util.Iterator;
import org.json.*;

public class json {
	public static void main(String[] args) {
		try{		
			Object[][] a1 ={{"T1","0va"},{"T2","1va"},{"T3","2va"}};
			Object[][] a2 ={{"M1","0vm"},{"M2","1vm"}};
			//System.out.println("a1's length:"+a1.length);
			//System.out.println("a1[0][0]:"+a1[0][0]);
			//System.out.println("a1[0][1]:"+a1[0][1]);
			Object[] a = new Object[2];
			a[0] = a1;
			a[1] = a2;
			System.out.println(array2string(a,2));
		}catch(Exception e){
		}
	}

	public conf conf;
	public static JSONObject clearJSONObject(JSONObject paramJobject1) {
		JSONObject localJobject1 = paramJobject1;
		try{
			for(Iterator it = localJobject1.keys(); it.hasNext(); ) { 
				String str1 = (String)it.next();
				localJobject1.remove(str1);
			} 
		}catch(Exception localException){			
		}
		return localJobject1;
	}

	public static JSONArray clearJSONArray(JSONArray paramJarray1) {
		JSONArray localJarray = paramJarray1;
		try{
			for(int i= 0 ; i<localJarray.length();i++) { 
				localJarray.remove(i);
			} 
		}catch(Exception localException){			
		}
		return localJarray;
	}
	
	public static String array2string(Object[] paramObject1) {
		String str1 = "";
		Object[] localObject1 = paramObject1;
		if (localObject1 != null) {
			Integer localInteger1 = paramObject1.length;
			str1 = array2string(localObject1, localInteger1);
		}
		return str1;
	}
	
	public static String array2string(Object[] paramObject1, Integer paramInger1) {
		String str1 = "";
		Object[] localObject1 = paramObject1;
		Integer localInteger1 = paramInger1;
		if (localObject1 != null) {
			try {
				JSONObject localJSONObject1 = new JSONObject();
				JSONArray localJSONArray = new JSONArray();
				localJSONObject1.put("total", localInteger1);

				for (int i = 0; i < localObject1.length; i++) {
					Object[][] localObject2 = (Object[][]) localObject1[i];
					JSONObject localJSONObject2 = new JSONObject();
					for (int j = 0; j < localObject2.length; j++) {
						localJSONObject2.put(cls.toString(localObject2[j][0]),
								cls.toString(localObject2[j][1]));
					}
					localJSONArray.put(localJSONObject2);
				}
				localJSONObject1.put("rows", localJSONArray);
				str1 = localJSONObject1.toString();
			} catch (JSONException localException) {
			}
		}
		return str1;
	}
}
